//
//  BaseHouseListCell.m
//  住房条件帅选器
//
//  Created by MB__Lee on 2018/5/17.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "BaseHouseListCell.h"
#import <UIImageView+WebCache.h>

@interface BaseHouseListCell()
@property (weak, nonatomic) IBOutlet UIImageView *bigImgV;

//标题--title
@property (weak, nonatomic) IBOutlet UILabel *MBtitleLabel;

//租金--rent
@property (weak, nonatomic) IBOutlet UILabel *rentLabel;

//小区名字---xq_name
@property (weak, nonatomic) IBOutlet UILabel *XQNameLabel;

//三个特色按钮
@property (weak, nonatomic) IBOutlet UILabel *moreLabelA;
@property (weak, nonatomic) IBOutlet UILabel *moreLabelB;
@property (weak, nonatomic) IBOutlet UILabel *moreLabelC;

// 数据组合label----根据不同的Category选用不同的数据
//住宅的时候: d_square ㎡/d_bedroom室d_livingroom厅
//商铺的时候：d_square ㎡/d_floor /d_total_floor层
@property (weak, nonatomic) IBOutlet UILabel *combination;

@end


@implementation BaseHouseListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.moreLabelA.hidden = YES;
     self.moreLabelB.hidden = YES;
     self.moreLabelC.hidden = YES;
    
}
-(void)setModel:(BaseHouseModel *)model{
    _model = model;
    
    

    //1、设置占位图
    [self.bigImgV sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageNamed:@"cellPlaceHolder"]];
    
    //2、 标题
    self.MBtitleLabel.text = model.title;
    
    //3、 小区
    self.XQNameLabel.text = model.xq_name;
    
    //4、设置组合label
    [self setCombinationLabelWithModel:model];
    
    //5、设置 特色文字
    if (model.label.count > 2) {
        self.moreLabelA.text = model.label[0];
        self.moreLabelB.text = model.label[1];
        self.moreLabelC.text = model.label[2];
        self.moreLabelA.hidden = NO;
        self.moreLabelB.hidden = NO;
        self.moreLabelC.hidden = NO;
        
    }else if (model.label.count > 1){
        self.moreLabelA.text = model.label[0];
        self.moreLabelB.text = model.label[1];
        
        self.moreLabelA.hidden = NO;
        self.moreLabelB.hidden = NO;
    }else if (model.label.count > 0){
        self.moreLabelA.text = model.label[0];
        self.moreLabelA.hidden = NO;
    }

}
//设置几室几厅、多少平米
-(void)setCombinationLabelWithModel:(BaseHouseModel *)model{
    
    NSString *realCategory = model.category;
     NSInteger intRent = [model.rent integerValue];
    if ([realCategory isEqualToString:@"1001"]) { //住宅
        
       
        
        self.rentLabel.text  = [NSString stringWithFormat:@"%zd元/月",intRent];
        
        self.combination.text = [NSString stringWithFormat:@"%@㎡/%@室%@厅",model.d_square,model.d_bedroom,model.d_livingroom];
        
        
    }else if ([realCategory isEqualToString:@"1002"]){ //公寓
        
    }else if ([realCategory isEqualToString:@"1003"]){// 写字楼
        self.rentLabel.text = [NSString stringWithFormat:@"%zd元/㎡/月",intRent];
        self.combination.text  = [NSString stringWithFormat:@"%@㎡ | %@/%@",model.d_square,model.d_floor,model.d_total_floor];
        
    }else if ([realCategory isEqualToString:@"1004"]){// 商铺
        self.rentLabel.text  = [NSString stringWithFormat:@"%zd元/月",intRent];
        
        self.combination.text  = [NSString stringWithFormat:@"%@㎡ | %@/%@",model.d_square,model.d_floor,model.d_total_floor];
        
        
    }
}





- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
